package yuyicman.display 
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import yuyicman.core.DestroyManager;
	import yuyicman.core.factory.Resource;
	import yuyicman.core.IDestroy;
	import yuyicman.debug.Debugger;
	
	/**
	 * ...
	 * @author Yuyic.
	 */
	public class ResourceUIbase extends MovieClip implements IDestroy
	{
		
		public var mc:MovieClip;
		
		public function ResourceUIbase( linkname:String ) 
		{
			try {
				mc = addChild( Resource.createDisplayObject( linkname ) ) as MovieClip;
			}
			catch (e:Error) {
				Debugger.log( e.getStackTrace() );
			}
		}
		
		public function destroy():void {
			
			if( mc ){
				removeChild( mc );
				mc = null;
			}
			if ( parent ) {
				parent.removeChild( this );
			}
			dispatchEvent( new Event( DestroyManager.DESTROY ) );
		}
		
	}

}